/**
	Pulsar engine. Core.
	Additional include file. String operations: filenames

	Copyright (C) 2013-2014 Dmitry Dolgov

	This program is free software; you can redistribute it and/or modify it under the terms of the
	GNU General Public License as published by the Free Software Foundation; either version 2 of
	the License, or (at your option) any later version.
		
	This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
	without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
	See the GNU General Public License for more details.
*/

namespace pl
{

/*
	canonizeFilename() options
*/
const pl_uint32 CANONIZE_REMOVE_SUBDOTS        = 0x00000001; // Remove .\ and ..\ from all pathes
const pl_uint32 CANONIZE_OPTIONS_SLASH         = 0x00000002; // Change all slashs with '/'
const pl_uint32 CANONIZE_OPTIONS_BACKSLASH     = 0x00000004; // Change all slashs with '\'
const pl_uint32 CANONIZE_OPTIONS_LOWERCASE     = 0x00000008; // Make all letters lowercase
const pl_uint32 CANONIZE_OPTIONS_UPPERCASE     = 0x00000010; // Make all letters uppercase
const pl_uint32 CANONIZE_OPTIONS_QUOTA_SPACE   = 0x00000020; // Add quotes of path contains spaces
const pl_uint32 CANONIZE_OPTIONS_DEQUOTA_SPACE = 0x00000040; // Remove quotes if possible
const pl_uint32 CANONIZE_OPTIONS_ISO9660       = 0x00000080; // Add ';1' for ISO 9660 compatible format

/// Standard file type
typedef String<MAX_PATH> Filepath;

/// Check is character delimiter
inline bool isPathDelimiter(pl_char c)
{
	return c == PL_T('/') || c == PL_T('\\');
}

/// Concatenate strings (add delimiter if need)
extern Filepath mergeFilename(const Filepath &path, const Filepath &fn);

/// Remove filename
extern Filepath removeFilename(const Filepath &fn);

/// Remove last extension
extern Filepath removeExtension(const Filepath &fn);

/// Replace extension with another one
extern Filepath replaceExtension(const Filepath &fn, const pl_char* extNew);

/// Extract filename
extern Filepath extractFilename(const Filepath &fn);

/// Get file extension
extern Filepath extractExtension(const Filepath &fn);

/// Get disk name (like C:\) or share name (\\server\share)
extern Filepath extractDrive(const Filepath &fn);

/// Convert absolute filename to relative accroding the given path
extern bool makeRelativePath(const Filepath &path, const Filepath &absName, Filepath &relName);

/// Canonize filename and change data
extern Filepath canonizeFilename(const Filepath &fn, pl_uint32 options = CANONIZE_REMOVE_SUBDOTS);

/// Compare filename with canonization
extern bool isEqualFilename(const Filepath &fn1, const Filepath &fn2, pl_uint32 options = CANONIZE_OPTIONS_SLASH);

/// Caluclate amount number of delimiters in path
extern int countDelimiter(const Filepath &name);

/// Check used delimiter (/ or \)
extern pl_char detectDelimiter(const Filepath &name);

/// Compare string with wildmask
extern bool wildCompare(const pl_char* wild, const pl_char* str);

} // namespace pl

//
// End of file 'pulsar_string_filename.h'
//
